package com.example.androidcomplete02.actionbar;

import android.app.ActionBar;
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.View;
import android.widget.Button;

import com.example.androidcomplete02.R;

public class ActionBarShowHide extends Activity {
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.ch21_actionbarshowhide);
	}

	public boolean onCreateOptionsMenu(Menu menu) {		
		MenuInflater inflater = getMenuInflater();
		inflater.inflate(R.menu.actionbarmenu, menu);
		return super.onCreateOptionsMenu(menu);
	}

	public void mOnClick(View v) {
		switch (v.getId()) {
		case R.id.btntoggle:
			ActionBar ab = getActionBar();
			if (ab.isShowing()) {
				ab.hide();
				((Button) v).setText("Show Action Bar");
			} else {
				ab.show();
				((Button) v).setText("Hide Action Bar");
			}
			break;
		}
	}
}